package org.brownflat.lighthouse.device.delcom;

import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean;

import org.apache.log4j.Logger;
import org.brownflat.lighthouse.action.delcom.DelcomAction;
import org.brownflat.lighthouse.device.Device;

public class DelcomBuildLight implements Device<DelcomAction> {
	
	private String executable;
	private AtomicBoolean isOn = new AtomicBoolean(Boolean.FALSE);
	private static final Logger LOG = Logger.getLogger(DelcomBuildLight.class);

	public DelcomBuildLight(String executable) {
		this.executable = executable;
	}

	public void execute(DelcomAction action) {
		Runtime run = Runtime.getRuntime();
		isOn.set(action.turnsOn());		
		try {
			run.exec(executable + " " + action.command());
		} catch (IOException e) {
			LOG.error(e);
		}
	}
}
